// 成绩类型定义 - 按班级管理
export interface Grade {
  id: number;
  educationStage: string; // 学段
  className: string; // 班级
  teachingCycle: string; // 教学周期
  examType: string; // 考试类型
  counselor: string; // 导员
  lecturer: string; // 讲师
  teacherId: string; // 教师号
  teachingProgress: string; // 教学进度
  totalStudents: number; // 总人数
  courseName: string;
  semester: string;
  examDate: string;
  teacherName: string;
  // 班级成绩统计数据
  averageScore: number; // 平均分
  passRate: number; // 及格率
  highScoreCount: number; // 高分人数
  failCount: number; // 不及格人数
}

// 模拟班级成绩数据
export const mockGradeData: Grade[] = [
  {
    id: 1,
    educationStage: '人工智能学段',
    className: '人工智能2411A',
    teachingCycle: '2023-2024学年',
    examType: '月考',
    counselor: '赵导员',
    lecturer: '李教授',
    teacherId: 'T2023001',
    teachingProgress: '专业1',
    totalStudents: 2,
    courseName: '高等数学',
    semester: '2023-2024第一学期',
    examDate: '2024-01-15',
    teacherName: '李教授',
    averageScore: 82.5,
    passRate: 95.6,
    highScoreCount: 12,
    failCount: 2
  },
  {
    id: 2,
    educationStage: '人工智能学段',
    className: '人工智能2411B',
    teachingCycle: '2023-2024学年',
    examType: '周考',
    counselor: '赵导员',
    lecturer: '王老师',
    teacherId: 'T2023002',
    teachingProgress: '专业1',
    totalStudents: 5,
    courseName: '程序设计基础',
    semester: '2023-2024第一学期',
    examDate: '2024-01-18',
    teacherName: '王老师',
    averageScore: 88.3,
    passRate: 100,
    highScoreCount: 18,
    failCount: 0
  },
  {
    id: 3,
    educationStage: '人工智能学段',
    className: '人工智能2412B',
    teachingCycle: '2023-2024学年',
    examType: '月考',
    counselor: '钱导员',
    lecturer: '李教授',
    teacherId: 'T2023001',
    teachingProgress: '专业2',
    totalStudents: 4,
    courseName: '高等数学',
    semester: '2023-2024第一学期',
    examDate: '2024-01-15',
    teacherName: '李教授',
    averageScore: 85.7,
    passRate: 97.6,
    highScoreCount: 15,
    failCount: 1
  },
  {
    id: 4,
    educationStage: '人工智能学段',
    className: '人工智能2412A',
    teachingCycle: '2023-2024学年',
    examType: '小高考',
    counselor: '钱导员',
    lecturer: '王老师',
    teacherId: 'T2023002',
    teachingProgress: '专业2',
    totalStudents: 2,
    courseName: '程序设计基础',
    semester: '2023-2024第一学期',
    examDate: '2024-01-18',
    teacherName: '王老师',
    averageScore: 84.2,
    passRate: 95.2,
    highScoreCount: 13,
    failCount: 2
  }
];

// 获取成绩列表的模拟API函数
export const getGrades = async (): Promise<Grade[]> => {
  // 模拟网络延迟
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve(mockGradeData);
    }, 500);
  });
};

// 获取特定班级的成绩的模拟API函数
export const getGradesByClassName = async (className: string): Promise<Grade[]> => {
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve(mockGradeData.filter(grade => grade.className === className));
    }, 300);
  });
};

// 获取特定学期的成绩的模拟API函数
export const getGradesBySemester = async (semester: string): Promise<Grade[]> => {
  return new Promise((resolve) => {
    setTimeout(() => {
      if (semester === 'all') {
        resolve(mockGradeData);
      } else {
        resolve(mockGradeData.filter(grade => grade.semester === semester));
      }
    }, 300);
  });
};